package main

import (
	"fmt"
	"sort"
)

func minSubsequence(nums []int) []int {
	res := make([]int, 0)
	sort.Ints(nums)
	total, current := 0, 0
	for _, num := range nums {
		total += num
	}

	for i := len(nums) - 1; i >= 0; i-- {
		res = append(res, nums[i])
		current += nums[i]
		if total-current < current {
			break
		}
	}
	return res
}

func main() {
	fmt.Println(minSubsequence([]int{4, 3, 10, 9, 8}))
	fmt.Println(minSubsequence([]int{4, 4, 7, 6, 7}))
	fmt.Println(minSubsequence([]int{6}))
}
